home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / language / xlisp_21.zoo / xlisp.doc < prev    next >
Text File  |  1990-02-28  |  81KB  |  3,241 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                          XLISP: An Object-oriented Lisp
  8.  
  9.                                   Version 2.0
  10.  
  11.                                 February 6, 1988
  12.  
  13.  
  14.                                        by
  15.                                David Michael Betz
  16.                                 127 Taylor Road
  17.                              Peterborough, NH 03458
  18.  
  19.                              (603) 924-6936 (home)
  20.                              (603) 882-1599 (BBS)
  21.  
  22.                    Copyright (c) 1988, by David Michael Betz
  23.                               All Rights Reserved
  24.            Permission is granted for unrestricted non-commercial use
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.         XLISP                  TABLE OF CONTENTS                  Page 2
  71.  
  72.  
  73.                                Table of Contents
  74.  
  75.  
  76.                 TABLE OF CONTENTS                        2
  77.  
  78.                 INTRODUCTION                             4
  79.  
  80.                 A NOTE FROM THE AUTHOR                   5
  81.  
  82.                 XLISP COMMAND LOOP                       6
  83.  
  84.                 BREAK COMMAND LOOP                       7
  85.  
  86.                 DATA TYPES                               8
  87.  
  88.                 THE EVALUATOR                            9
  89.  
  90.                 LEXICAL CONVENTIONS                     10
  91.  
  92.                 READTABLES                              11
  93.  
  94.                 LAMBDA LISTS                            12
  95.  
  96.                 OBJECTS                                 14
  97.  
  98.                 SYMBOLS                                 17
  99.  
  100.                 EVALUATION FUNCTIONS                    18
  101.  
  102.                 SYMBOL FUNCTIONS                        19
  103.  
  104.                 PROPERTY LIST FUNCTIONS                 21
  105.  
  106.                 ARRAY FUNCTIONS                         22
  107.  
  108.                 LIST FUNCTIONS                          23
  109.  
  110.                 DESTRUCTIVE LIST FUNCTIONS              26
  111.  
  112.                 PREDICATE FUNCTIONS                     27
  113.  
  114.                 CONTROL CONSTRUCTS                      29
  115.  
  116.                 LOOPING CONSTRUCTS                      31
  117.  
  118.                 THE PROGRAM FEATURE                     32
  119.  
  120.                 DEBUGGING AND ERROR HANDLING            33
  121.  
  122.                 ARITHMETIC FUNCTIONS                    34
  123.  
  124.                 BITWISE LOGICAL FUNCTIONS               36
  125.  
  126.                 STRING FUNCTIONS                        37
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.         XLISP                  TABLE OF CONTENTS                  Page 3
  137.  
  138.  
  139.                 CHARACTER FUNCTIONS                     39
  140.  
  141.                 INPUT/OUTPUT FUNCTIONS                  41
  142.  
  143.                 THE FORMAT FUNCTION                     42
  144.  
  145.                 FILE I/O FUNCTIONS                      43
  146.  
  147.                 STRING STREAM FUNCTIONS                 44
  148.  
  149.                 SYSTEM FUNCTIONS                        45
  150.  
  151.                 EXAMPLES                                47
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.         XLISP                     INTRODUCTION                    Page 4
  203.  
  204.  
  205.         INTRODUCTION
  206.  
  207.         XLISP is an experimental programming language combining some of
  208.         the features of Common Lisp with an object-oriented extension
  209.         capability.  It was implemented to allow experimentation with
  210.         object-oriented programming on small computers.
  211.  
  212.         There are currently implementations of XLISP running on the IBM-
  213.         PC and clones under MS-DOS, on the Macintosh, the Atari-ST and
  214.         the Amiga.  It is completely written in the programming language
  215.         'C' and is easily extended with user written built-in functions
  216.         and classes.  It is available in source form to non-commercial
  217.         users.
  218.  
  219.         Many Common Lisp functions are built into XLISP.  In addition,
  220.         XLISP defines the objects 'Object' and 'Class' as primitives.
  221.         'Object' is the only class that has no superclass and hence is
  222.         the root of the class heirarchy tree.  'Class' is the class of
  223.         which all classes are instances (it is the only object that is
  224.         an instance of itself).
  225.  
  226.         This document is a brief description of XLISP.  It assumes some
  227.         knowledge of LISP and some understanding of the concepts of
  228.         object-oriented programming.
  229.  
  230.         I recommend the book "LISP" by Winston and Horn and published by
  231.         Addison Wesley for learning Lisp.  The first edition of this
  232.         book is based on MacLisp and the second edition is based on
  233.         Common Lisp.  XLISP will continue to migrate towards
  234.         compatibility with Common Lisp.
  235.  
  236.         You will probably also need a copy of "Common Lisp: The
  237.         Language" by Guy L. Steele, Jr., published by Digital Press to
  238.         use as a reference for some of the Common Lisp functions that
  239.         are described only briefly in this document.
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.         XLISP                A NOTE FROM THE AUTHOR               Page 5
  269.  
  270.  
  271.         A NOTE FROM THE AUTHOR
  272.  
  273.         If you have any problems with XLISP, feel free to contact me for
  274.         help or advice.  Please remember that since XLISP is available
  275.         in source form in a high level language, many users have been
  276.         making versions available on a variety of machines.  If you call
  277.         to report a problem with a specific version, I may not be able
  278.         to help you if that version runs on a machine to which I don't
  279.         have access.  Please have the version number of the version that
  280.         you are running readily accessible before calling me.
  281.  
  282.         If you find a bug in XLISP, first try to fix the bug yourself
  283.         using the source code provided.  If you are successful in fixing
  284.         the bug, send the bug report along with the fix to me.  If you
  285.         don't have access to a C compiler or are unable to fix a bug,
  286.         please send the bug report to me and I'll try to fix it.
  287.  
  288.         Any suggestions for improvements will be welcomed.  Feel free to
  289.         extend the language in whatever way suits your needs.  However,
  290.         PLEASE DO NOT RELEASE ENHANCED VERSIONS WITHOUT CHECKING WITH ME
  291.         FIRST!!  I would like to be the clearing house for new features
  292.         added to XLISP.  If you want to add features for your own
  293.         personal use, go ahead.  But, if you want to distribute your
  294.         enhanced version, contact me first.  Please remember that the
  295.         goal of XLISP is to provide a language to learn and experiment
  296.         with LISP and object-oriented programming on small computers.  I
  297.         don't want it to get so big that it requires megabytes of memory
  298.         to run.
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.         XLISP                 XLISP COMMAND LOOP                  Page 6
  335.  
  336.  
  337.         XLISP COMMAND LOOP
  338.  
  339.         When XLISP is started, it first tries to load the workspace
  340.         "xlisp.wks" from the current directory.  If that file doesn't
  341.         exist, XLISP builds an initial workspace, empty except for the
  342.         built-in functions and symbols.
  343.  
  344.         Then XLISP attempts to load "init.lsp" from the current
  345.         directory.  It then loads any files named as parameters on the
  346.         command line (after appending ".lsp" to their names).
  347.  
  348.         XLISP then issues the following prompt:
  349.  
  350.         >
  351.  
  352.         This indicates that XLISP is waiting for an expression to be
  353.         typed.
  354.  
  355.         When a complete expression has been entered, XLISP attempts to
  356.         evaluate that expression.  If the expression evaluates
  357.         successfully, XLISP prints the result and then returns to the
  358.         initial prompt waiting for another expression to be typed.
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.         XLISP                 BREAK COMMAND LOOP                  Page 7
  401.  
  402.  
  403.         BREAK COMMAND LOOP
  404.  
  405.         When XLISP encounters an error while evaluating an expression,
  406.         it attempts to handle the error in the following way:
  407.  
  408.         If the symbol '*breakenable*' is true, the message corresponding
  409.         to the error is printed.  If the error is correctable, the
  410.         correction message is printed.
  411.  
  412.         If the symbol '*tracenable*' is true, a trace back is printed.
  413.         The number of entries printed depends on the value of the symbol
  414.         '*tracelimit*'.  If this symbol is set to something other than a
  415.         number, the entire trace back stack is printed.
  416.  
  417.         XLISP then enters a read/eval/print loop to allow the user to
  418.         examine the state of the interpreter in the context of the
  419.         error.  This loop differs from the normal top-level
  420.         read/eval/print loop in that if the user invokes the function
  421.         'continue', XLISP will continue from a correctable error.  If
  422.         the user invokes the function 'clean-up', XLISP will abort the
  423.         break loop and return to the top level or the next lower
  424.         numbered break loop.  When in a break loop, XLISP prefixes the
  425.         break level to the normal prompt.
  426.  
  427.         If the symbol '*breakenable*' is nil, XLISP looks for a
  428.         surrounding errset function.  If one is found, XLISP examines
  429.         the value of the print flag.  If this flag is true, the error
  430.         message is printed.  In any case, XLISP causes the errset
  431.         function call to return nil.
  432.  
  433.         If there is no surrounding errset function, XLISP prints the
  434.         error message and returns to the top level.
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.         XLISP                      DATA TYPES                     Page 8
  467.  
  468.  
  469.         DATA TYPES
  470.  
  471.         There are several different data types available to XLISP
  472.         programmers.
  473.  
  474.             o lists
  475.             o symbols
  476.             o strings
  477.             o integers
  478.             o characters
  479.             o floats
  480.             o objects
  481.             o arrays
  482.             o streams
  483.             o subrs (built-in functions)
  484.             o fsubrs (special forms)
  485.             o closures (user defined functions)
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.         XLISP                    THE EVALUATOR                    Page 9
  533.  
  534.  
  535.         THE EVALUATOR
  536.  
  537.         The process of evaluation in XLISP:
  538.  
  539.         Strings, integers, characters, floats, objects, arrays, streams,
  540.         subrs, fsubrs and closures evaluate to themselves.
  541.  
  542.         Symbols act as variables and are evaluated by retrieving the
  543.         value associated with their current binding.
  544.  
  545.         Lists are evaluated by examining the first element of the list
  546.         and then taking one of the following actions:
  547.  
  548.             If it is a symbol, the functional binding of the symbol is
  549.             retrieved.
  550.  
  551.             If it is a lambda expression, a closure is constructed for
  552.             the function described by the lambda expression.
  553.  
  554.             If it is a subr, fsubr or closure, it stands for itself.
  555.  
  556.             Any other value is an error.
  557.  
  558.         Then, the value produced by the previous step is examined:
  559.  
  560.             If it is a subr or closure, the remaining list elements are
  561.             evaluated and the subr or closure is called with these
  562.             evaluated expressions as arguments.
  563.  
  564.             If it is an fsubr, the fsubr is called using the remaining
  565.             list elements as arguments (unevaluated).
  566.  
  567.             If it is a macro, the macro is expanded using the remaining
  568.             list elements as arguments (unevaluated).  The macro
  569.             expansion is then evaluated in place of the original macro
  570.             call.
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.         XLISP                 LEXICAL CONVENTIONS                Page 10
  599.  
  600.  
  601.         LEXICAL CONVENTIONS
  602.  
  603.         The following conventions must be followed when entering XLISP
  604.         programs:
  605.  
  606.         Comments in XLISP code begin with a semi-colon character and
  607.         continue to the end of the line.
  608.  
  609.         Symbol names in XLISP can consist of any sequence of non-blank
  610.         printable characters except the following:
  611.  
  612.                 ( ) ' ` , " ;
  613.  
  614.         Uppercase and lowercase characters are not distinguished within
  615.         symbol names.  All lowercase characters are mapped to uppercase
  616.         on input.
  617.  
  618.         Integer literals consist of a sequence of digits optionally
  619.         beginning with a '+' or '-'.  The range of values an integer can
  620.         represent is limited by the size of a C 'long' on the machine on
  621.         which XLISP is running.
  622.  
  623.         Floating point literals consist of a sequence of digits
  624.         optionally beginning with a '+' or '-' and including an embedded
  625.         decimal point.  The range of values a floating point number can
  626.         represent is limited by the size of a C 'float' ('double' on
  627.         machines with 32 bit addresses) on the machine on which XLISP is
  628.         running.
  629.  
  630.         Literal strings are sequences of characters surrounded by double
  631.         quotes.  Within quoted strings the '\' character is used to
  632.         allow non-printable characters to be included.  The codes
  633.         recognized are:
  634.  
  635.                 \\        means the character '\'
  636.                 \n       means newline
  637.                 \t       means tab
  638.                 \r       means return
  639.                 \f       means form feed
  640.                 \nnn     means the character whose octal code is nnn
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.         XLISP                      READTABLES                    Page 11
  665.  
  666.  
  667.         READTABLES
  668.  
  669.         The behaviour of the reader is controlled by a data structure
  670.         called a "readtable".  The reader uses the symbol *READTABLE* to
  671.         locate the current readtable.  This table controls the
  672.         interpretation of input characters.  It is an array with 128
  673.         entries, one for each of the ASCII character codes.  Each entry
  674.         contains one of the following things:
  675.  
  676.                 NIL             Indicating an invalid character
  677.                 :CONSTITUENT    Indicating a symbol constituent
  678.                 :WHITE-SPACE    Indicating a whitespace character
  679.                 (:TMACRO . fun) Terminating readmacro
  680.                 (:NMACRO . fun) Non-terminating readmacro
  681.                 :SESCAPE        Single escape character ('\')
  682.                 :MESCAPE        Multiple escape character ('|')
  683.  
  684.         In the case of :TMACRO and :NMACRO, the "fun" component is a
  685.         function.  This can either be a built-in readmacro function or a
  686.         lambda expression.  The function should take two parameters.
  687.         The first is the input stream and the second is the character
  688.         that caused the invocation of the readmacro.  The readmacro
  689.         function should return NIL to indicate that the character should
  690.         be treated as white space or a value consed with NIL to indicate
  691.         that the readmacro should be treated as an occurance of the
  692.         specified value.  Of course, the readmacro code is free to read
  693.         additional characters from the input stream.
  694.  
  695.         XLISP defines several useful read macros:
  696.  
  697.                 '<expr>         == (quote <expr>)
  698.                 #'<expr>        == (function <expr>)
  699.                 #(<expr>...)    == an array of the specified expressions
  700.                 #x<hdigits>     == a hexadecimal number (0-9,A-F)
  701.                 #o<odigits>     == an octal number (0-7)
  702.                 #b<bdigits>     == a binary number (0-1)
  703.                 #\<char> == the ASCII code of the character
  704.                 #| ... |#       == a comment
  705.                 #:<symbol>      == an uninterned symbol
  706.                 `<expr>         == (backquote <expr>)
  707.                 ,<expr>         == (comma <expr>)
  708.                 ,@<expr>        == (comma-at <expr>)
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.         XLISP                     LAMBDA LISTS                   Page 12
  731.  
  732.  
  733.         LAMBDA LISTS
  734.  
  735.         There are several forms in XLISP that require that a "lambda
  736.         list" be specified.  A lambda list is a definition of the
  737.         arguments accepted by a function.  There are four different
  738.         types of arguments.
  739.  
  740.         The lambda list starts with required arguments.  Required
  741.         arguments must be specified in every call to the function.
  742.  
  743.         The required arguments are followed by the &optional arguments.
  744.         Optional arguments may be provided or omitted in a call.  An
  745.         initialization expression may be specified to provide a default
  746.         value for an &optional argument if it is omitted from a call.
  747.         If no initialization expression is specified, an omitted
  748.         argument is initialized to NIL.  It is also possible to provide
  749.         the name of a 'supplied-p' variable that can be used to
  750.         determine if a call provided a value for the argument or if the
  751.         initialization expression was used.  If specified, the supplied-
  752.         p variable will be bound to T if a value was specified in the
  753.         call and NIL if the default value was used.
  754.  
  755.         The &optional arguments are followed by the &rest argument.  The
  756.         &rest argument gets bound to the remainder of the argument list
  757.         after the required and &optional arguments have been removed.
  758.  
  759.         The &rest argument is followed by the &key arguments.  When a
  760.         keyword argument is passed to a function, a pair of values
  761.         appears in the argument list.  The first expression in the pair
  762.         should evaluate to a keyword symbol (a symbol that begins with a
  763.         ':').  The value of the second expression is the value of the
  764.         keyword argument.  Like &optional arguments, &key arguments can
  765.         have initialization expressions and supplied-p variables.  In
  766.         addition, it is possible to specify the keyword to be used in a
  767.         function call.  If no keyword is specified, the keyword obtained
  768.         by adding a ':' to the beginning of the keyword argument symbol
  769.         is used.  In other words, if the keyword argument symbol is
  770.         'foo', the keyword will be ':foo'.
  771.  
  772.         The &key arguments are followed by the &aux variables.  These
  773.         are local variables that are bound during the evaluation of the
  774.         function body.  It is possible to have initialization
  775.         expressions for the &aux variables.
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.         XLISP                     LAMBDA LISTS                   Page 13
  797.  
  798.  
  799.         Here is the complete syntax for lambda lists:
  800.  
  801.                 (<rarg>...
  802.                  [&optional [<oarg> | (<oarg> [<init> [<svar>]])]...]
  803.                  [&rest <rarg>]
  804.                  [&key
  805.                    [<karg> | ([<karg> | (<key> <karg>)] [<init> [<svar>]])]...
  806.                    &allow-other-keys]
  807.                  [&aux
  808.                    [<aux> | (<aux> [<init>])]...])
  809.  
  810.             where:
  811.  
  812.                 <rarg>  is a required argument symbol
  813.                 <oarg>  is an &optional argument symbol
  814.                 <rarg>  is the &rest argument symbol
  815.                 <karg>  is a &key argument symbol
  816.                 <key>   is a keyword symbol
  817.                 <aux>   is an auxiliary variable symbol
  818.                 <init>  is an initialization expression
  819.                 <svar>  is a supplied-p variable symbol
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.         XLISP                       OBJECTS                      Page 14
  863.  
  864.  
  865.         OBJECTS
  866.  
  867.         Definitions:
  868.  
  869.             o selector - a symbol used to select an appropriate method
  870.             o message - a selector and a list of actual arguments
  871.             o method - the code that implements a message
  872.  
  873.         Since XLISP was created to provide a simple basis for
  874.         experimenting with object-oriented programming, one of the
  875.         primitive data types included is 'object'.  In XLISP, an object
  876.         consists of a data structure containing a pointer to the
  877.         object's class as well as an array containing the values of the
  878.         object's instance variables.
  879.  
  880.         Officially, there is no way to see inside an object (look at the
  881.         values of its instance variables).  The only way to communicate
  882.         with an object is by sending it a message.
  883.  
  884.         You can send a message to an object using the 'send' function.
  885.         This function takes the object as its first argument, the
  886.         message selector as its second argument (which must be a symbol)
  887.         and the message arguments as its remaining arguments.
  888.  
  889.         The 'send' function determines the class of the receiving object
  890.         and attempts to find a method corresponding to the message
  891.         selector in the set of messages defined for that class.  If the
  892.         message is not found in the object's class and the class has a
  893.         super-class, the search continues by looking at the messages
  894.         defined for the super-class.  This process continues from one
  895.         super-class to the next until a method for the message is found.
  896.         If no method is found, an error occurs.
  897.  
  898.         A message can also be sent from the body of a method by using
  899.         the current object, but the method lookup starts with the
  900.         object's superclass rather than its class.  This allows a
  901.         subclass to invoke a standard method in its parent class even
  902.         though it overrides that method with its own specialized
  903.         version.
  904.  
  905.         When a method is found, the evaluator binds the receiving object
  906.         to the symbol 'self' and evaluates the method using the
  907.         remaining elements of the original list as arguments to the
  908.         method.  These arguments are always evaluated prior to being
  909.         bound to their corresponding formal arguments.  The result of
  910.         evaluating the method becomes the result of the expression.
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.         XLISP                       OBJECTS                      Page 15
  929.  
  930.  
  931.         THE 'Object' CLASS
  932.  
  933.         Classes:
  934.  
  935.         Object  THE TOP OF THE CLASS HEIRARCHY
  936.  
  937.             Messages:
  938.  
  939.                 :show  SHOW AN OBJECT'S INSTANCE VARIABLES
  940.                     returns     the object
  941.  
  942.                 :class  RETURN THE CLASS OF AN OBJECT
  943.                     returns     the class of the object
  944.  
  945.                 :isnew  THE DEFAULT OBJECT INITIALIZATION ROUTINE
  946.                     returns     the object
  947.  
  948.                 :sendsuper <sel> <args>...  SEND SUPERCLASS A MESSAGE
  949.                     <sel>       the message selector
  950.                     <args>      the message arguments
  951.                     returns     the result of sending the message
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.         XLISP                       OBJECTS                      Page 16
  995.  
  996.  
  997.         THE 'Class' CLASS
  998.  
  999.         Class   THE CLASS OF ALL OBJECT CLASSES (including itself)
  1000.  
  1001.             Messages:
  1002.  
  1003.                 :new  CREATE A NEW INSTANCE OF A CLASS
  1004.                     returns     the new class object
  1005.  
  1006.                 :isnew <ivars> [<cvars> [<super>]]  INITIALIZE A NEW CLASS
  1007.                     <ivars>     the list of instance variable symbols
  1008.                     <cvars>     the list of class variable symbols
  1009.                     <super>     the superclass (default is Object)
  1010.                     returns     the new class object
  1011.  
  1012.                 :answer <msg> <fargs> <code>  ADD A MESSAGE TO A CLASS
  1013.                     <msg>       the message symbol
  1014.                     <fargs>     the formal argument list (lambda list)
  1015.                     <code>      a list of executable expressions
  1016.                     returns     the object
  1017.  
  1018.  
  1019.         When a new instance of a class is created by sending the message
  1020.         ':new' to an existing class, the message ':isnew' followed by
  1021.         whatever parameters were passed to the ':new' message is sent to
  1022.         the newly created object.
  1023.  
  1024.         When a new class is created by sending the ':new' message to the
  1025.         object 'Class', an optional parameter may be specified
  1026.         indicating the superclass of the new class.  If this parameter
  1027.         is omitted, the new class will be a subclass of 'Object'.  A
  1028.         class inherits all instance variables, class variables, and
  1029.         methods from its super-class.
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.         XLISP                       SYMBOLS                      Page 17
  1061.  
  1062.  
  1063.         SYMBOLS
  1064.  
  1065.             o self - the current object (within a method context)
  1066.             o *obarray* - the object hash table
  1067.             o *standard-input* - the standard input stream
  1068.             o *standard-output* - the standard output stream
  1069.             o *error-output* - the error output stream
  1070.             o *trace-output* - the trace output stream
  1071.             o *debug-io* - the debug i/o stream
  1072.             o *breakenable* - flag controlling entering break loop on errors
  1073.             o *tracelist* - list of names of functions to trace
  1074.             o *tracenable* - enable trace back printout on errors
  1075.             o *tracelimit* - number of levels of trace back information
  1076.             o *evalhook* - user substitute for the evaluator function
  1077.             o *applyhook* - (not yet implemented)
  1078.             o *readtable* - the current readtable
  1079.             o *unbound* - indicator for unbound symbols
  1080.             o *gc-flag* - controls the printing of gc messages
  1081.             o *gc-hook* - function to call after garbage collection
  1082.             o *integer-format* - format for printing integers ("%d" or "%ld")
  1083.             o *float-format* - format for printing floats ("%g")
  1084.             o *print-case* - symbol output case (:upcase or :downcase)
  1085.  
  1086.         There are several symbols maintained by the read/eval/print
  1087.         loop.  The symbols '+', '++', and '+++' are bound to the most
  1088.         recent three input expressions.  The symbols '*', '**' and '***'
  1089.         are bound to the most recent three results.  The symbol '-' is
  1090.         bound to the expression currently being evaluated.  It becomes
  1091.         the value of '+' at the end of the evaluation.
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.         XLISP                 EVALUATION FUNCTIONS               Page 18
  1127.  
  1128.  
  1129.         EVALUATION FUNCTIONS
  1130.  
  1131.         (eval <expr>)  EVALUATE AN XLISP EXPRESSION
  1132.             <expr>      the expression to be evaluated
  1133.             returns     the result of evaluating the expression
  1134.  
  1135.         (apply <fun> <args>)  APPLY A FUNCTION TO A LIST OF ARGUMENTS
  1136.             <fun>       the function to apply (or function symbol)
  1137.             <args>      the argument list
  1138.             returns     the result of applying the function to the arguments
  1139.  
  1140.         (funcall <fun> <arg>...)  CALL A FUNCTION WITH ARGUMENTS
  1141.             <fun>       the function to call (or function symbol)
  1142.             <arg>       arguments to pass to the function
  1143.             returns     the result of calling the function with the arguments
  1144.  
  1145.         (quote <expr>)  RETURN AN EXPRESSION UNEVALUATED
  1146.             <expr>      the expression to be quoted (quoted)
  1147.             returns     <expr> unevaluated
  1148.  
  1149.         (function <expr>)  GET THE FUNCTIONAL INTERPRETATION
  1150.             <expr>      the symbol or lambda expression (quoted)
  1151.             returns     the functional interpretation
  1152.  
  1153.         (backquote <expr>)  FILL IN A TEMPLATE
  1154.             <expr>      the template
  1155.             returns     a copy of the template with comma and comma-at
  1156.                         expressions expanded
  1157.  
  1158.         (lambda <args> <expr>...)  MAKE A FUNCTION CLOSURE
  1159.             <args>      formal argument list (lambda list) (quoted)
  1160.             <expr>      expressions of the function body
  1161.             returns     the function closure
  1162.  
  1163.         (get-lambda-expression <closure>)  GET THE LAMBDA EXPRESSION
  1164.             <closure>   the closure
  1165.             returns     the original lambda expression
  1166.  
  1167.         (macroexpand <form>)  RECURSIVELY EXPAND MACRO CALLS
  1168.             <form>      the form to expand
  1169.             returns     the macro expansion
  1170.  
  1171.         (macroexpand-1 <form>)  EXPAND A MACRO CALL
  1172.             <form>      the macro call form
  1173.             returns     the macro expansion
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.         XLISP                   SYMBOL FUNCTIONS                 Page 19
  1193.  
  1194.  
  1195.         SYMBOL FUNCTIONS
  1196.  
  1197.         (set <sym> <expr>)  SET THE VALUE OF A SYMBOL
  1198.             <sym>       the symbol being set
  1199.             <expr>      the new value
  1200.             returns     the new value
  1201.  
  1202.         (setq [<sym> <expr>]...)  SET THE VALUE OF A SYMBOL
  1203.             <sym>       the symbol being set (quoted)
  1204.             <expr>      the new value
  1205.             returns     the new value
  1206.  
  1207.         (psetq [<sym> <expr>]...)  PARALLEL VERSION OF SETQ
  1208.             <sym>       the symbol being set (quoted)
  1209.             <expr>      the new value
  1210.             returns     the new value
  1211.  
  1212.         (setf [<place> <expr>]...)  SET THE VALUE OF A FIELD
  1213.             <place>     the field specifier (quoted):
  1214.                           <sym>                   set value of a symbol
  1215.                           (car <expr>)            set car of a cons node
  1216.                           (cdr <expr>)            set cdr of a cons node
  1217.                           (nth <n> <expr>)        set nth car of a list
  1218.                           (aref <expr> <n>)       set nth element of an array
  1219.                           (get <sym> <prop>)      set value of a property
  1220.                           (symbol-value <sym>)    set value of a symbol
  1221.                           (symbol-function <sym>) set functional value of a symbol
  1222.                           (symbol-plist <sym>)    set property list of a symbol
  1223.             <value>     the new value
  1224.             returns     the new value
  1225.  
  1226.         (defun <sym> <fargs> <expr>...)  DEFINE A FUNCTION
  1227.         (defmacro <sym> <fargs> <expr>...)  DEFINE A MACRO
  1228.             <sym>       symbol being defined (quoted)
  1229.             <fargs>     formal argument list (lambda list) (quoted)
  1230.             <expr>      expressions constituting the body of the
  1231.                         function (quoted)
  1232.             returns     the function symbol
  1233.  
  1234.         (gensym [<tag>])  GENERATE A SYMBOL
  1235.             <tag>       string or number
  1236.             returns     the new symbol
  1237.  
  1238.         (intern <pname>)  MAKE AN INTERNED SYMBOL
  1239.             <pname>     the symbol's print name string
  1240.             returns     the new symbol
  1241.  
  1242.         (make-symbol <pname>)  MAKE AN UNINTERNED SYMBOL
  1243.             <pname>     the symbol's print name string
  1244.             returns     the new symbol
  1245.  
  1246.         (symbol-name <sym>)  GET THE PRINT NAME OF A SYMBOL
  1247.             <sym>       the symbol
  1248.             returns     the symbol's print name
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.         XLISP                   SYMBOL FUNCTIONS                 Page 20
  1259.  
  1260.  
  1261.         (symbol-value <sym>)  GET THE VALUE OF A SYMBOL
  1262.             <sym>       the symbol
  1263.             returns     the symbol's value
  1264.  
  1265.         (symbol-function <sym>)  GET THE FUNCTIONAL VALUE OF A SYMBOL
  1266.             <sym>       the symbol
  1267.             returns     the symbol's functional value
  1268.  
  1269.         (symbol-plist <sym>)  GET THE PROPERTY LIST OF A SYMBOL
  1270.             <sym>       the symbol
  1271.             returns     the symbol's property list
  1272.  
  1273.         (hash <sym> <n>)  COMPUTE THE HASH INDEX FOR A SYMBOL
  1274.             <sym>       the symbol or string
  1275.             <n>         the table size (integer)
  1276.             returns     the hash index (integer)
  1277.  
  1278.  
  1279.  
  1280.  
  1281.  
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.         XLISP               PROPERTY LIST FUNCTIONS              Page 21
  1325.  
  1326.  
  1327.         PROPERTY LIST FUNCTIONS
  1328.  
  1329.         (get <sym> <prop>)  GET THE VALUE OF A PROPERTY
  1330.             <sym>       the symbol
  1331.             <prop>      the property symbol
  1332.             returns     the property value or nil
  1333.  
  1334.         (putprop <sym> <val> <prop>)  PUT A PROPERTY ONTO A PROPERTY LIST
  1335.             <sym>       the symbol
  1336.             <val>       the property value
  1337.             <prop>      the property symbol
  1338.             returns     the property value
  1339.  
  1340.         (remprop <sym> <prop>)  REMOVE A PROPERTY
  1341.             <sym>       the symbol
  1342.             <prop>      the property symbol
  1343.             returns     nil
  1344.  
  1345.  
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.         XLISP                   ARRAY FUNCTIONS                  Page 22
  1391.  
  1392.  
  1393.         ARRAY FUNCTIONS
  1394.  
  1395.         (aref <array> <n>)  GET THE NTH ELEMENT OF AN ARRAY
  1396.             <array>     the array
  1397.             <n>         the array index (integer)
  1398.             returns     the value of the array element
  1399.  
  1400.         (make-array <size>)  MAKE A NEW ARRAY
  1401.             <size>      the size of the new array (integer)
  1402.             returns     the new array
  1403.  
  1404.         (vector <expr>...)  MAKE AN INITIALIZED VECTOR
  1405.             <expr>      the vector elements
  1406.             returns     the new vector
  1407.  
  1408.  
  1409.  
  1410.  
  1411.  
  1412.  
  1413.  
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.         XLISP                    LIST FUNCTIONS                  Page 23
  1457.  
  1458.  
  1459.         LIST FUNCTIONS
  1460.  
  1461.         (car <expr>)  RETURN THE CAR OF A LIST NODE
  1462.             <expr>      the list node
  1463.             returns     the car of the list node
  1464.  
  1465.         (cdr <expr>)  RETURN THE CDR OF A LIST NODE
  1466.             <expr>      the list node
  1467.             returns     the cdr of the list node
  1468.  
  1469.         (cxxr <expr>)  ALL CxxR COMBINATIONS
  1470.         (cxxxr <expr>)  ALL CxxxR COMBINATIONS
  1471.         (cxxxxr <expr>)  ALL CxxxxR COMBINATIONS
  1472.  
  1473.         (first <expr>)   A SYNONYM FOR CAR
  1474.         (second <expr>)  A SYNONYM FOR CADR
  1475.         (third <expr>)   A SYNONYM FOR CADDR
  1476.         (fourth <expr>)  A SYNONYM FOR CADDDR
  1477.         (rest <expr>)    A SYNONYM FOR CDR
  1478.  
  1479.         (cons <expr1> <expr2>)  CONSTRUCT A NEW LIST NODE
  1480.             <expr1>     the car of the new list node
  1481.             <expr2>     the cdr of the new list node
  1482.             returns     the new list node
  1483.  
  1484.         (list <expr>...)  CREATE A LIST OF VALUES
  1485.             <expr>      expressions to be combined into a list
  1486.             returns     the new list
  1487.  
  1488.         (append <expr>...)  APPEND LISTS
  1489.             <expr>      lists whose elements are to be appended
  1490.             returns     the new list
  1491.  
  1492.         (reverse <expr>)  REVERSE A LIST
  1493.             <expr>      the list to reverse
  1494.             returns     a new list in the reverse order
  1495.  
  1496.         (last <list>)  RETURN THE LAST LIST NODE OF A LIST
  1497.             <list>      the list
  1498.             returns     the last list node in the list
  1499.  
  1500.         (member <expr> <list> &key :test :test-not)  FIND AN EXPRESSION IN A LIST
  1501.             <expr>      the expression to find
  1502.             <list>      the list to search
  1503.             :test       the test function (defaults to eql)
  1504.             :test-not   the test function (sense inverted)      
  1505.             returns     the remainder of the list starting with the expression
  1506.  
  1507.         (assoc <expr> <alist> &key :test :test-not)  FIND AN EXPRESSION IN AN A-LIST
  1508.             <expr>      the expression to find
  1509.             <alist>     the association list
  1510.             :test       the test function (defaults to eql)
  1511.             :test-not   the test function (sense inverted)      
  1512.             returns     the alist entry or nil
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.         XLISP                    LIST FUNCTIONS                  Page 24
  1523.  
  1524.  
  1525.         (remove <expr> <list> &key :test :test-not)  REMOVE ELEMENTS FROM A LIST
  1526.             <expr>      the element to remove
  1527.             <list>      the list
  1528.             :test       the test function (defaults to eql)
  1529.             :test-not   the test function (sense inverted)      
  1530.             returns     copy of list with matching expressions removed
  1531.  
  1532.         (remove-if <test> <list>)  REMOVE ELEMENTS THAT PASS TEST
  1533.             <test>      the test predicate
  1534.             <list>      the list
  1535.             returns     copy of list with matching elements removed
  1536.  
  1537.         (remove-if-not <test> <list>)  REMOVE ELEMENTS THAT FAIL TEST
  1538.             <test>      the test predicate
  1539.             <list>      the list
  1540.             returns     copy of list with non-matching elements removed
  1541.  
  1542.         (length <expr>)  FIND THE LENGTH OF A LIST, VECTOR OR STRING
  1543.             <expr>      the list, vector or string
  1544.             returns     the length of the list, vector or string
  1545.  
  1546.         (nth <n> <list>)  RETURN THE NTH ELEMENT OF A LIST
  1547.             <n>         the number of the element to return (zero origin)
  1548.             <list>      the list
  1549.             returns     the nth element or nil if the list isn't that long
  1550.  
  1551.         (nthcdr <n> <list>)  RETURN THE NTH CDR OF A LIST
  1552.             <n>         the number of the element to return (zero origin)
  1553.             <list>      the list
  1554.             returns     the nth cdr or nil if the list isn't that long
  1555.  
  1556.         (mapc <fcn> <list1> <list>...)  APPLY FUNCTION TO SUCCESSIVE CARS
  1557.             <fcn>       the function or function name
  1558.             <listn>     a list for each argument of the function
  1559.             returns     the first list of arguments
  1560.  
  1561.         (mapcar <fcn> <list1> <list>...)  APPLY FUNCTION TO SUCCESSIVE CARS
  1562.             <fcn>       the function or function name
  1563.             <listn>     a list for each argument of the function
  1564.             returns     a list of the values returned
  1565.  
  1566.         (mapl <fcn> <list1> <list>...)  APPLY FUNCTION TO SUCCESSIVE CDRS
  1567.             <fcn>       the function or function name
  1568.             <listn>     a list for each argument of the function
  1569.             returns     the first list of arguments
  1570.  
  1571.         (maplist <fcn> <list1> <list>...)  APPLY FUNCTION TO SUCCESSIVE CDRS
  1572.             <fcn>       the function or function name
  1573.             <listn>     a list for each argument of the function
  1574.             returns     a list of the values returned
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.         XLISP                    LIST FUNCTIONS                  Page 25
  1589.  
  1590.  
  1591.         (subst <to> <from> <expr> &key :test :test-not)  SUBSTITUTE EXPRESSIONS
  1592.             <to>        the new expression
  1593.             <from>      the old expression
  1594.             <expr>      the expression in which to do the substitutions
  1595.             :test       the test function (defaults to eql)
  1596.             :test-not   the test function (sense inverted)      
  1597.             returns     the expression with substitutions
  1598.  
  1599.         (sublis <alist> <expr> &key :test :test-not)  SUBSTITUTE WITH AN A-LIST
  1600.             <alist>     the association list
  1601.             <expr>      the expression in which to do the substitutions
  1602.             :test       the test function (defaults to eql)
  1603.             :test-not   the test function (sense inverted)      
  1604.             returns     the expression with substitutions
  1605.  
  1606.  
  1607.  
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613.         XLISP              DESTRUCTIVE LIST FUNCTIONS            Page 26
  1614.  
  1615.  
  1616.         DESTRUCTIVE LIST FUNCTIONS
  1617.  
  1618.         (rplaca <list> <expr>)  REPLACE THE CAR OF A LIST NODE
  1619.             <list>      the list node
  1620.             <expr>      the new value for the car of the list node
  1621.             returns     the list node after updating the car
  1622.  
  1623.         (rplacd <list> <expr>)  REPLACE THE CDR OF A LIST NODE
  1624.             <list>      the list node
  1625.             <expr>      the new value for the cdr of the list node
  1626.             returns     the list node after updating the cdr
  1627.  
  1628.         (nconc <list>...)  DESTRUCTIVELY CONCATENATE LISTS
  1629.             <list>      lists to concatenate
  1630.             returns     the result of concatenating the lists
  1631.  
  1632.         (delete <expr> &key :test :test-not)  DELETE ELEMENTS FROM A LIST
  1633.             <expr>      the element to delete
  1634.             <list>      the list
  1635.             :test       the test function (defaults to eql)
  1636.             :test-not   the test function (sense inverted)      
  1637.             returns     the list with the matching expressions deleted
  1638.  
  1639.         (delete-if <test> <list>)  DELETE ELEMENTS THAT PASS TEST
  1640.             <test>      the test predicate
  1641.             <list>      the list
  1642.             returns     the list with matching elements deleted
  1643.  
  1644.         (delete-if-not <test> <list>)  DELETE ELEMENTS THAT FAIL TEST
  1645.             <test>      the test predicate
  1646.             <list>      the list
  1647.             returns     the list with non-matching elements deleted
  1648.  
  1649.         (sort <list> <test>)  SORT A LIST
  1650.             <list>      the list to sort
  1651.             <test>      the comparison function
  1652.             returns     the sorted list
  1653.  
  1654.  
  1655.  
  1656.  
  1657.  
  1658.  
  1659.  
  1660.  
  1661.  
  1662.  
  1663.  
  1664.  
  1665.  
  1666.  
  1667.  
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.         XLISP                 PREDICATE FUNCTIONS                Page 27
  1680.  
  1681.  
  1682.         PREDICATE FUNCTIONS
  1683.  
  1684.         (atom <expr>)  IS THIS AN ATOM?
  1685.             <expr>      the expression to check
  1686.             returns     t if the value is an atom, nil otherwise
  1687.  
  1688.         (symbolp <expr>)  IS THIS A SYMBOL?
  1689.             <expr>      the expression to check
  1690.             returns     t if the expression is a symbol, nil otherwise
  1691.  
  1692.         (numberp <expr>)  IS THIS A NUMBER?
  1693.             <expr>      the expression to check
  1694.             returns     t if the expression is a number, nil otherwise
  1695.  
  1696.         (null <expr>)  IS THIS AN EMPTY LIST?
  1697.             <expr>      the list to check
  1698.             returns     t if the list is empty, nil otherwise
  1699.  
  1700.         (not <expr>)  IS THIS FALSE?
  1701.             <expr>      the expression to check
  1702.             return      t if the value is nil, nil otherwise
  1703.  
  1704.         (listp <expr>)  IS THIS A LIST?
  1705.             <expr>      the expression to check
  1706.             returns     t if the value is a cons or nil, nil otherwise
  1707.  
  1708.         (endp <list>)  IS THIS THE END OF A LIST
  1709.             <list>      the list
  1710.             returns     t if the value is nil, nil otherwise
  1711.  
  1712.         (consp <expr>)  IS THIS A NON-EMPTY LIST?
  1713.             <expr>      the expression to check
  1714.             returns     t if the value is a cons, nil otherwise
  1715.  
  1716.         (integerp <expr>)  IS THIS AN INTEGER?
  1717.             <expr>      the expression to check
  1718.             returns     t if the value is an integer, nil otherwise
  1719.  
  1720.         (floatp <expr>)  IS THIS A FLOAT?
  1721.             <expr>      the expression to check
  1722.             returns     t if the value is a float, nil otherwise
  1723.  
  1724.         (stringp <expr>)  IS THIS A STRING?
  1725.             <expr>      the expression to check
  1726.             returns     t if the value is a string, nil otherwise
  1727.  
  1728.         (characterp <expr>)  IS THIS A CHARACTER?
  1729.             <expr>      the expression to check
  1730.             returns     t if the value is a character, nil otherwise
  1731.  
  1732.         (arrayp <expr>)  IS THIS AN ARRAY?
  1733.             <expr>      the expression to check
  1734.             returns     t if the value is an array, nil otherwise
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
  1740.  
  1741.  
  1742.  
  1743.  
  1744.  
  1745.         XLISP                 PREDICATE FUNCTIONS                Page 28
  1746.  
  1747.  
  1748.         (streamp <expr>)  IS THIS A STREAM?
  1749.             <expr>      the expression to check
  1750.             returns     t if the value is a stream, nil otherwise
  1751.  
  1752.         (objectp <expr>)  IS THIS AN OBJECT?
  1753.             <expr>      the expression to check
  1754.             returns     t if the value is an object, nil otherwise
  1755.  
  1756.         (boundp <sym>)  IS A VALUE BOUND TO THIS SYMBOL?
  1757.             <sym>       the symbol
  1758.             returns     t if a value is bound to the symbol, nil otherwise
  1759.  
  1760.         (fboundp <sym>)  IS A FUNCTIONAL VALUE BOUND TO THIS SYMBOL?
  1761.             <sym>       the symbol
  1762.             returns     t if a functional value is bound to the symbol,
  1763.                         nil otherwise
  1764.  
  1765.         (minusp <expr>)  IS THIS NUMBER NEGATIVE?
  1766.             <expr>      the number to test
  1767.             returns     t if the number is negative, nil otherwise
  1768.  
  1769.         (zerop <expr>)  IS THIS NUMBER ZERO?
  1770.             <expr>      the number to test
  1771.             returns     t if the number is zero, nil otherwise
  1772.  
  1773.         (plusp <expr>)  IS THIS NUMBER POSITIVE?
  1774.             <expr>      the number to test
  1775.             returns     t if the number is positive, nil otherwise
  1776.  
  1777.         (evenp <expr>)  IS THIS INTEGER EVEN?
  1778.             <expr>      the integer to test
  1779.             returns     t if the integer is even, nil otherwise
  1780.  
  1781.         (oddp <expr>)  IS THIS INTEGER ODD?
  1782.             <expr>      the integer to test
  1783.             returns     t if the integer is odd, nil otherwise
  1784.  
  1785.         (eq <expr1> <expr2>)  ARE THE EXPRESSIONS IDENTICAL?
  1786.             <expr1>     the first expression
  1787.             <expr2>     the second expression
  1788.             returns     t if they are equal, nil otherwise
  1789.  
  1790.         (eql <expr1> <expr2>)  ARE THE EXPRESSIONS IDENTICAL?
  1791.                                 (WORKS WITH ALL NUMBERS)
  1792.             <expr1>     the first expression
  1793.             <expr2>     the second expression
  1794.             returns     t if they are equal, nil otherwise
  1795.  
  1796.         (equal <expr1> <expr2>)  ARE THE EXPRESSIONS EQUAL?
  1797.             <expr1>     the first expression
  1798.             <expr2>     the second expression
  1799.             returns     t if they are equal, nil otherwise
  1800.  
  1801.  
  1802.  
  1803.  
  1804.  
  1805.  
  1806.  
  1807.  
  1808.  
  1809.  
  1810.  
  1811.         XLISP                  CONTROL CONSTRUCTS                Page 29
  1812.  
  1813.  
  1814.         CONTROL CONSTRUCTS
  1815.  
  1816.         (cond <pair>...)  EVALUATE CONDITIONALLY
  1817.             <pair>      pair consisting of:
  1818.                             (<pred> <expr>...)
  1819.                           where
  1820.                             <pred>      is a predicate expression
  1821.                             <expr>      evaluated if the predicate
  1822.                                         is not nil
  1823.             returns     the value of the first expression whose predicate
  1824.                         is not nil
  1825.  
  1826.         (and <expr>...)  THE LOGICAL AND OF A LIST OF EXPRESSIONS
  1827.             <expr>      the expressions to be ANDed
  1828.             returns     nil if any expression evaluates to nil,
  1829.                         otherwise the value of the last expression
  1830.                         (evaluation of expressions stops after the first
  1831.                          expression that evaluates to nil)
  1832.  
  1833.         (or <expr>...)  THE LOGICAL OR OF A LIST OF EXPRESSIONS
  1834.             <expr>      the expressions to be ORed
  1835.             returns     nil if all expressions evaluate to nil,
  1836.                         otherwise the value of the first non-nil expression
  1837.                         (evaluation of expressions stops after the first
  1838.                          expression that does not evaluate to nil)
  1839.  
  1840.         (if <texpr> <expr1> [<expr2>])  EVALUATE EXPRESSIONS CONDITIONALLY
  1841.             <texpr>     the test expression
  1842.             <expr1>     the expression to be evaluated if texpr is non-nil
  1843.             <expr2>     the expression to be evaluated if texpr is nil
  1844.             returns     the value of the selected expression
  1845.  
  1846.         (when <texpr> <expr>...)  EVALUATE ONLY WHEN A CONDITION IS TRUE
  1847.             <texpr>     the test expression
  1848.             <expr>      the expression(s) to be evaluted if texpr is non-nil
  1849.             returns     the value of the last expression or nil
  1850.  
  1851.         (unless <texpr> <expr>...)  EVALUATE ONLY WHEN A CONDITION IS FALSE
  1852.             <texpr>     the test expression
  1853.             <expr>      the expression(s) to be evaluated if texpr is nil
  1854.             returns     the value of the last expression or nil
  1855.  
  1856.           (case <expr> <case>...)  SELECT BY CASE
  1857.             <expr>      the selection expression
  1858.             <case>      pair consisting of:
  1859.                             (<value> <expr>...)
  1860.                           where:
  1861.                             <value>     is a single expression or a list of
  1862.                                         expressions (unevaluated)
  1863.                             <expr>      are expressions to execute if the
  1864.                                         case matches
  1865.             returns     the value of the last expression of the matching case
  1866.  
  1867.  
  1868.  
  1869.  
  1870.  
  1871.  
  1872.  
  1873.  
  1874.  
  1875.  
  1876.  
  1877.         XLISP                  CONTROL CONSTRUCTS                Page 30
  1878.  
  1879.  
  1880.         (let (<binding>...) <expr>...)  CREATE LOCAL BINDINGS
  1881.         (let* (<binding>...) <expr>...)  LET WITH SEQUENTIAL BINDING
  1882.             <binding>   the variable bindings each of which is either:
  1883.                         1)  a symbol (which is initialized to nil)
  1884.                         2)  a list whose car is a symbol and whose cadr
  1885.                                 is an initialization expression
  1886.             <expr>      the expressions to be evaluated
  1887.             returns     the value of the last expression
  1888.  
  1889.         (flet (<binding>...) <expr>...)  CREATE LOCAL FUNCTIONS
  1890.         (labels (<binding>...) <expr>...)  FLET WITH RECURSIVE FUNCTIONS
  1891.         (macrolet (<binding>...) <expr>...)  CREATE LOCAL MACROS
  1892.             <binding>   the function bindings each of which is:
  1893.                           (<sym> <fargs> <expr>...)
  1894.                         where:
  1895.                             <sym>       the function/macro name
  1896.                             <fargs>     formal argument list (lambda list)
  1897.                             <expr>      expressions constituting the body of
  1898.                                         the function/macro
  1899.             <expr>      the expressions to be evaluated
  1900.             returns     the value of the last expression
  1901.  
  1902.         (catch <sym> <expr>...)  EVALUATE EXPRESSIONS AND CATCH THROWS
  1903.             <sym>       the catch tag
  1904.             <expr>      expressions to evaluate
  1905.             returns     the value of the last expression the throw expression
  1906.  
  1907.         (throw <sym> [<expr>])  THROW TO A CATCH
  1908.             <sym>       the catch tag
  1909.             <expr>      the value for the catch to return (defaults to nil)
  1910.             returns     never returns
  1911.  
  1912.         (unwind-protect <expr> <cexpr>...)  PROTECT EVALUATION OF AN EXPRESSION
  1913.             <expr>      the expression to protect
  1914.             <cexpr>     the cleanup expressions
  1915.             returns     the value of the expression
  1916.           Note:  unwind-protect guarantees to execute the cleanup expressions
  1917.                  even if a non-local exit terminates the evaluation of the
  1918.                  protected expression
  1919.  
  1920.  
  1921.  
  1922.  
  1923.  
  1924.  
  1925.  
  1926.  
  1927.  
  1928.  
  1929.  
  1930.  
  1931.  
  1932.  
  1933.  
  1934.  
  1935.  
  1936.  
  1937.  
  1938.  
  1939.  
  1940.  
  1941.  
  1942.  
  1943.         XLISP                  LOOPING CONSTRUCTS                Page 31
  1944.  
  1945.  
  1946.         LOOPING CONSTRUCTS
  1947.  
  1948.         (loop <expr>...)  BASIC LOOPING FORM
  1949.             <expr>      the body of the loop
  1950.             returns     never returns (must use non-local exit)
  1951.  
  1952.         (do (<binding>...) (<texpr> <rexpr>...) <expr>...)
  1953.         (do* (<binding>...) (<texpr> <rexpr>...) <expr>...)
  1954.             <binding>   the variable bindings each of which is either:
  1955.                         1)  a symbol (which is initialized to nil)
  1956.                         2)  a list of the form: (<sym> <init> [<step>])
  1957.                             where:
  1958.                                 <sym>  is the symbol to bind
  1959.                                 <init> is the initial value of the symbol
  1960.                                 <step> is a step expression
  1961.             <texpr>     the termination test expression
  1962.             <rexpr>     result expressions (the default is nil)
  1963.             <expr>      the body of the loop (treated like an implicit prog)
  1964.             returns     the value of the last result expression
  1965.  
  1966.         (dolist (<sym> <expr> [<rexpr>]) <expr>...)  LOOP THROUGH A LIST
  1967.             <sym>       the symbol to bind to each list element
  1968.             <expr>      the list expression
  1969.             <rexpr>     the result expression (the default is nil)
  1970.             <expr>      the body of the loop (treated like an implicit prog)
  1971.  
  1972.         (dotimes (<sym> <expr> [<rexpr>]) <expr>...)  LOOP FROM ZERO TO N-1
  1973.             <sym>       the symbol to bind to each value from 0 to n-1
  1974.             <expr>      the number of times to loop
  1975.             <rexpr>     the result expression (the default is nil)
  1976.             <expr>      the body of the loop (treated like an implicit prog)
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.  
  1986.  
  1987.  
  1988.  
  1989.  
  1990.  
  1991.  
  1992.  
  1993.  
  1994.  
  1995.  
  1996.  
  1997.  
  1998.  
  1999.  
  2000.  
  2001.  
  2002.  
  2003.  
  2004.  
  2005.  
  2006.  
  2007.  
  2008.  
  2009.         XLISP                 THE PROGRAM FEATURE                Page 32
  2010.  
  2011.  
  2012.         THE PROGRAM FEATURE
  2013.  
  2014.         (prog (<binding>...) <expr>...)  THE PROGRAM FEATURE
  2015.         (prog* (<binding>...) <expr>...)  PROG WITH SEQUENTIAL BINDING
  2016.             <binding>   the variable bindings each of which is either:
  2017.                         1)  a symbol (which is initialized to nil)
  2018.                         2)  a list whose car is a symbol and whose cadr
  2019.                                 is an initialization expression
  2020.             <expr>      expressions to evaluate or tags (symbols)
  2021.             returns     nil or the argument passed to the return function
  2022.  
  2023.         (block <name> <expr>...)  NAMED BLOCK
  2024.             <name>      the block name (symbol)
  2025.             <expr>      the block body
  2026.             returns     the value of the last expression
  2027.  
  2028.         (return [<expr>])  CAUSE A PROG CONSTRUCT TO RETURN A VALUE
  2029.             <expr>      the value (defaults to nil)
  2030.             returns     never returns
  2031.  
  2032.         (return-from <name> [<value>])  RETURN FROM A NAMED BLOCK
  2033.             <name>      the block name (symbol)
  2034.             <value>     the value to return (defaults to nil)
  2035.             returns     never returns
  2036.  
  2037.         (tagbody <expr>...)  BLOCK WITH LABELS
  2038.             <expr>      expression(s) to evaluate or tags (symbols)
  2039.             returns     nil
  2040.  
  2041.         (go <sym>)  GO TO A TAG WITHIN A TAGBODY OR PROG
  2042.             <sym>       the tag (quoted)
  2043.             returns     never returns
  2044.  
  2045.         (progv <slist> <vlist> <expr>...)  DYNAMICALLY BIND SYMBOLS
  2046.             <slist>     list of symbols
  2047.             <vlist>     list of values to bind to the symbols
  2048.             <expr>      expression(s) to evaluate
  2049.             returns     the value of the last expression
  2050.  
  2051.         (prog1 <expr1> <expr>...)  EXECUTE EXPRESSIONS SEQUENTIALLY
  2052.             <expr1>     the first expression to evaluate
  2053.             <expr>      the remaining expressions to evaluate
  2054.             returns     the value of the first expression
  2055.  
  2056.         (prog2 <expr1> <expr2> <expr>...)  EXECUTE EXPRESSIONS SEQUENTIALLY
  2057.             <expr1>     the first expression to evaluate
  2058.             <expr2>     the second expression to evaluate
  2059.             <expr>      the remaining expressions to evaluate
  2060.             returns     the value of the second expression
  2061.  
  2062.         (progn <expr>...)  EXECUTE EXPRESSIONS SEQUENTIALLY
  2063.             <expr>      the expressions to evaluate
  2064.             returns     the value of the last expression (or nil)
  2065.  
  2066.  
  2067.  
  2068.  
  2069.  
  2070.  
  2071.  
  2072.  
  2073.  
  2074.  
  2075.         XLISP             DEBUGGING AND ERROR HANDLING           Page 33
  2076.  
  2077.  
  2078.         DEBUGGING AND ERROR HANDLING
  2079.  
  2080.         (trace <sym>)  ADD A FUNCTION TO THE TRACE LIST
  2081.             <sym>       the function to add (quoted)
  2082.             returns     the trace list
  2083.  
  2084.         (untrace <sym>)  REMOVE A FUNCTION FROM THE TRACE LIST
  2085.             <sym>       the function to remove (quoted)
  2086.             returns     the trace list
  2087.  
  2088.         (error <emsg> [<arg>])  SIGNAL A NON-CORRECTABLE ERROR
  2089.             <emsg>      the error message string
  2090.             <arg>       the argument expression (printed after the message)
  2091.             returns     never returns
  2092.  
  2093.         (cerror <cmsg> <emsg> [<arg>])  SIGNAL A CORRECTABLE ERROR
  2094.             <cmsg>      the continue message string
  2095.             <emsg>      the error message string
  2096.             <arg>       the argument expression (printed after the message)
  2097.             returns     nil when continued from the break loop
  2098.  
  2099.         (break [<bmsg> [<arg>]])  ENTER A BREAK LOOP
  2100.             <bmsg>      the break message string (defaults to "**BREAK**")
  2101.             <arg>       the argument expression (printed after the message)
  2102.             returns     nil when continued from the break loop
  2103.  
  2104.         (clean-up)  CLEAN-UP AFTER AN ERROR
  2105.             returns     never returns
  2106.  
  2107.         (top-level)  CLEAN-UP AFTER AN ERROR AND RETURN TO THE TOP LEVEL
  2108.             returns     never returns
  2109.  
  2110.         (continue)  CONTINUE FROM A CORRECTABLE ERROR
  2111.             returns     never returns
  2112.  
  2113.         (errset <expr> [<pflag>])  TRAP ERRORS
  2114.             <expr>      the expression to execute
  2115.             <pflag>     flag to control printing of the error message
  2116.             returns     the value of the last expression consed with nil
  2117.                         or nil on error
  2118.  
  2119.         (baktrace [<n>])  PRINT N LEVELS OF TRACE BACK INFORMATION
  2120.             <n>         the number of levels (defaults to all levels)
  2121.             returns     nil
  2122.  
  2123.         (evalhook <expr> <ehook> <ahook> [<env>])  EVALUATE WITH HOOKS
  2124.             <expr>      the expression to evaluate
  2125.             <ehook>     the value for *evalhook*
  2126.             <ahook>     the value for *applyhook*
  2127.             <env>       the environment (default is nil)
  2128.             returns     the result of evaluating the expression
  2129.  
  2130.  
  2131.  
  2132.  
  2133.  
  2134.  
  2135.  
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141.         XLISP                 ARITHMETIC FUNCTIONS               Page 34
  2142.  
  2143.  
  2144.         ARITHMETIC FUNCTIONS
  2145.  
  2146.         (truncate <expr>)  TRUNCATES A FLOATING POINT NUMBER TO AN INTEGER
  2147.             <expr>      the number
  2148.             returns     the result of truncating the number
  2149.  
  2150.         (float <expr>)  CONVERTS AN INTEGER TO A FLOATING POINT NUMBER
  2151.             <expr>      the number
  2152.             returns     the result of floating the integer
  2153.  
  2154.         (+ <expr>...)  ADD A LIST OF NUMBERS
  2155.             <expr>      the numbers
  2156.             returns     the result of the addition
  2157.  
  2158.         (- <expr>...)  SUBTRACT A LIST OF NUMBERS OR NEGATE A SINGLE NUMBER
  2159.             <expr>      the numbers
  2160.             returns     the result of the subtraction
  2161.  
  2162.         (* <expr>...)  MULTIPLY A LIST OF NUMBERS
  2163.             <expr>      the numbers
  2164.             returns     the result of the multiplication
  2165.  
  2166.         (/ <expr>...)  DIVIDE A LIST OF NUMBERS
  2167.             <expr>      the numbers
  2168.             returns     the result of the division
  2169.  
  2170.         (1+ <expr>)  ADD ONE TO A NUMBER
  2171.             <expr>      the number
  2172.             returns     the number plus one
  2173.  
  2174.         (1- <expr>)  SUBTRACT ONE FROM A NUMBER
  2175.             <expr>      the number
  2176.             returns     the number minus one
  2177.  
  2178.         (rem <expr>...)  REMAINDER OF A LIST OF NUMBERS
  2179.             <expr>      the numbers
  2180.             returns     the result of the remainder operation
  2181.  
  2182.         (min <expr>...)  THE SMALLEST OF A LIST OF NUMBERS
  2183.             <expr>      the expressions to be checked
  2184.             returns     the smallest number in the list
  2185.  
  2186.         (max <expr>...)  THE LARGEST OF A LIST OF NUMBERS
  2187.             <expr>      the expressions to be checked
  2188.             returns     the largest number in the list
  2189.  
  2190.         (abs <expr>)  THE ABSOLUTE VALUE OF A NUMBER
  2191.             <expr>      the number
  2192.             returns     the absolute value of the number
  2193.  
  2194.         (gcd <n1> <n2>...)  COMPUTE THE GREATEST COMMON DIVISOR
  2195.             <n1>        the first number (integer)
  2196.             <n2>        the second number(s) (integer)
  2197.             returns     the greatest common divisor
  2198.  
  2199.  
  2200.  
  2201.  
  2202.  
  2203.  
  2204.  
  2205.  
  2206.  
  2207.         XLISP                 ARITHMETIC FUNCTIONS               Page 35
  2208.  
  2209.  
  2210.         (random <n>)  COMPUTE A RANDOM NUMBER BETWEEN 1 and N-1
  2211.             <n>         the upper bound (integer)
  2212.             returns     a random number
  2213.  
  2214.         (sin <expr>)  COMPUTE THE SINE OF A NUMBER
  2215.             <expr>      the floating point number
  2216.             returns     the sine of the number
  2217.  
  2218.         (cos <expr>)  COMPUTE THE COSINE OF A NUMBER
  2219.             <expr>      the floating point number
  2220.             returns     the cosine of the number
  2221.  
  2222.         (tan <expr>)  COMPUTE THE TANGENT OF A NUMBER
  2223.             <expr>      the floating point number
  2224.             returns     the tangent of the number
  2225.  
  2226.         (expt <x-expr> <y-expr>)  COMPUTE X TO THE Y POWER
  2227.             <x-expr>    the floating point number
  2228.             <y-expr>    the floating point exponent
  2229.             returns     x to the y power
  2230.  
  2231.         (exp <x-expr>)  COMPUTE E TO THE X POWER
  2232.             <x-expr>    the floating point number
  2233.             returns     e to the x power
  2234.  
  2235.         (sqrt <expr>)  COMPUTE THE SQUARE ROOT OF A NUMBER
  2236.             <expr>      the floating point number
  2237.             returns     the square root of the number
  2238.  
  2239.         (< <n1> <n2>...)  TEST FOR LESS THAN
  2240.         (<= <n1> <n2>...)  TEST FOR LESS THAN OR EQUAL TO
  2241.         (= <n1> <n2>...)  TEST FOR EQUAL TO
  2242.         (/= <n1> <n2>...)  TEST FOR NOT EQUAL TO
  2243.         (>= <n1> <n2>...)  TEST FOR GREATER THAN OR EQUAL TO
  2244.         (> <n1> <n2>...)  TEST FOR GREATER THAN
  2245.             <n1>        the first number to compare
  2246.             <n2>        the second number to compare
  2247.             returns     the result of comparing <n1> with <n2>...
  2248.  
  2249.  
  2250.  
  2251.  
  2252.  
  2253.  
  2254.  
  2255.  
  2256.  
  2257.  
  2258.  
  2259.  
  2260.  
  2261.  
  2262.  
  2263.  
  2264.  
  2265.  
  2266.  
  2267.  
  2268.  
  2269.  
  2270.  
  2271.  
  2272.  
  2273.         XLISP              BITWISE LOGICAL FUNCTIONS             Page 36
  2274.  
  2275.  
  2276.         BITWISE LOGICAL FUNCTIONS
  2277.  
  2278.         (logand <expr>...)  THE BITWISE AND OF A LIST OF NUMBERS
  2279.             <expr>      the numbers
  2280.             returns     the result of the and operation
  2281.  
  2282.         (logior <expr>...)  THE BITWISE INCLUSIVE OR OF A LIST OF NUMBERS
  2283.             <expr>      the numbers
  2284.             returns     the result of the inclusive or operation
  2285.  
  2286.         (logxor <expr>...)  THE BITWISE EXCLUSIVE OR OF A LIST OF NUMBERS
  2287.             <expr>      the numbers
  2288.             returns     the result of the exclusive or operation
  2289.  
  2290.         (lognot <expr>)  THE BITWISE NOT OF A NUMBER
  2291.             <expr>      the number
  2292.             returns     the bitwise inversion of number
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.  
  2315.  
  2316.  
  2317.  
  2318.  
  2319.  
  2320.  
  2321.  
  2322.  
  2323.  
  2324.  
  2325.  
  2326.  
  2327.  
  2328.  
  2329.  
  2330.  
  2331.  
  2332.  
  2333.  
  2334.  
  2335.  
  2336.  
  2337.  
  2338.  
  2339.         XLISP                   STRING FUNCTIONS                 Page 37
  2340.  
  2341.  
  2342.         STRING FUNCTIONS
  2343.  
  2344.         (string <expr>)  MAKE A STRING FROM AN INTEGER ASCII VALUE
  2345.             <expr>      the integer
  2346.             returns     a one character string
  2347.  
  2348.         (string-trim <bag> <str>)  TRIM BOTH ENDS OF A STRING
  2349.             <bag>       a string containing characters to trim
  2350.             <str>       the string to trim
  2351.             returns     a trimed copy of the string
  2352.  
  2353.         (string-left-trim <bag> <str>)  TRIM THE LEFT END OF A STRING
  2354.             <bag>       a string containing characters to trim
  2355.             <str>       the string to trim
  2356.             returns     a trimed copy of the string
  2357.  
  2358.         (string-right-trim <bag> <str>)  TRIM THE RIGHT END OF A STRING
  2359.             <bag>       a string containing characters to trim
  2360.             <str>       the string to trim
  2361.             returns     a trimed copy of the string
  2362.  
  2363.         (string-upcase <str> &key :start :end)  CONVERT TO UPPERCASE
  2364.             <str>       the string
  2365.             :start      the starting offset
  2366.             :end        the ending offset + 1
  2367.             returns     a converted copy of the string
  2368.  
  2369.         (string-downcase <str> &key :start :end)  CONVERT TO LOWERCASE
  2370.             <str>       the string
  2371.             :start      the starting offset
  2372.             :end        the ending offset + 1
  2373.             returns     a converted copy of the string
  2374.  
  2375.         (nstring-upcase <str> &key :start :end)  CONVERT TO UPPERCASE
  2376.             <str>       the string
  2377.             :start      the starting offset
  2378.             :end        the ending offset + 1
  2379.             returns     the converted string (not a copy)
  2380.  
  2381.         (nstring-downcase <str> &key :start :end)  CONVERT TO LOWERCASE
  2382.             <str>       the string
  2383.             :start      the starting offset
  2384.             :end        the ending offset + 1
  2385.             returns     the converted string (not a copy)
  2386.  
  2387.         (strcat <expr>...)  CONCATENATE STRINGS
  2388.             <expr>      the strings to concatenate
  2389.             returns     the result of concatenating the strings
  2390.  
  2391.         (subseq <string> <start> [<end>]) EXTRACT A SUBSTRING
  2392.             <string>    the string
  2393.             <start>     the starting position (zero origin)
  2394.             <end>       the ending position + 1 (defaults to end)
  2395.             returns     substring between <start> and <end>
  2396.  
  2397.  
  2398.  
  2399.  
  2400.  
  2401.  
  2402.  
  2403.  
  2404.  
  2405.         XLISP                   STRING FUNCTIONS                 Page 38
  2406.  
  2407.  
  2408.         (string< <str1> <str2> &key :start1 :end1 :start2 :end2)
  2409.         (string<= <str1> <str2> &key :start1 :end1 :start2 :end2)
  2410.         (string= <str1> <str2> &key :start1 :end1 :start2 :end2)
  2411.         (string/= <str1> <str2> &key :start1 :end1 :start2 :end2)
  2412.         (string>= <str1> <str2> &key :start1 :end1 :start2 :end2)
  2413.         (string> <str1> <str2> &key :start1 :end1 :start2 :end2)
  2414.             <str1>      the first string to compare
  2415.             <str2>      the second string to compare
  2416.             :start1     first substring starting offset
  2417.             :end1       first substring ending offset + 1
  2418.             :start2     second substring starting offset
  2419.             :end2       second substring ending offset + 1
  2420.             returns     t if predicate is true, nil otherwise
  2421.           Note: case is significant with these comparison functions.
  2422.  
  2423.         (string-lessp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2424.         (string-not-greaterp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2425.         (string-equalp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2426.         (string-not-equalp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2427.         (string-not-lessp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2428.         (string-greaterp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2429.             <str1>      the first string to compare
  2430.             <str2>      the second string to compare
  2431.             :start1     first substring starting offset
  2432.             :end1       first substring ending offset + 1
  2433.             :start2     second substring starting offset
  2434.             :end2       second substring ending offset + 1
  2435.             returns     t if predicate is true, nil otherwise
  2436.           Note: case is not significant with these comparison functions.
  2437.  
  2438.  
  2439.  
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.  
  2447.  
  2448.  
  2449.  
  2450.  
  2451.  
  2452.  
  2453.  
  2454.  
  2455.  
  2456.  
  2457.  
  2458.  
  2459.  
  2460.  
  2461.  
  2462.  
  2463.  
  2464.  
  2465.  
  2466.  
  2467.  
  2468.  
  2469.  
  2470.  
  2471.         XLISP                 CHARACTER FUNCTIONS                Page 39
  2472.  
  2473.  
  2474.         CHARACTER FUNCTIONS
  2475.  
  2476.         (char <string> <index>)  EXTRACT A CHARACTER FROM A STRING
  2477.             <string>    the string
  2478.             <index>     the string index (zero relative)
  2479.             returns     the ascii code of the character
  2480.  
  2481.         (upper-case-p <chr>)  IS THIS AN UPPER CASE CHARACTER?
  2482.             <chr>       the character
  2483.             returns     true if the character is upper case, nil otherwise
  2484.  
  2485.         (lower-case-p <chr>)  IS THIS A LOWER CASE CHARACTER?
  2486.             <chr>       the character
  2487.             returns     true if the character is lower case, nil otherwise
  2488.  
  2489.         (both-case-p <chr>)  IS THIS AN ALPHABETIC (EITHER CASE) CHARACTER?
  2490.             <chr>       the character
  2491.             returns     true if the character is alphabetic, nil otherwise
  2492.  
  2493.         (digit-char-p <chr>)  IS THIS A DIGIT CHARACTER?
  2494.             <chr>       the character
  2495.             returns     the digit weight if character is a digit, nil otherwise
  2496.  
  2497.         (char-code <chr>)  GET THE ASCII CODE OF A CHARACTER
  2498.             <chr>       the character
  2499.             returns     the ASCII character code (integer)
  2500.  
  2501.         (code-char <code>)  GET THE CHARACTER WITH A SPECFIED ASCII CODE
  2502.             <code>      the ASCII code (integer)
  2503.             returns     the character with that code or nil
  2504.  
  2505.         (char-upcase <chr>)  CONVERT A CHARACTER TO UPPER CASE
  2506.             <chr>       the character
  2507.             returns     the upper case character
  2508.  
  2509.         (char-downcase <chr>)  CONVERT A CHARACTER TO LOWER CASE
  2510.             <chr>       the character
  2511.             returns     the lower case character
  2512.  
  2513.         (digit-char <n>)  CONVERT A DIGIT WEIGHT TO A DIGIT
  2514.             <n>         the digit weight (integer)
  2515.             returns     the digit character or nil
  2516.  
  2517.         (char-int <chr>) CONVERT A CHARACTER TO AN INTEGER
  2518.             <chr>       the character
  2519.             returns     the ASCII character code
  2520.  
  2521.         (int-char <int>) CONVERT AN INTEGER TO A CHARACTER
  2522.             <int>       the ASCII character code
  2523.             returns     the character with that code
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529.  
  2530.  
  2531.  
  2532.  
  2533.  
  2534.  
  2535.  
  2536.  
  2537.         XLISP                 CHARACTER FUNCTIONS                Page 40
  2538.  
  2539.  
  2540.         (char< <chr1> <chr2>...)
  2541.         (char<= <chr1> <chr2>...)
  2542.         (char= <chr1> <chr2>...)
  2543.         (char/= <chr1> <chr2>...)
  2544.         (char>= <chr1> <chr2>...)
  2545.         (char> <chr1> <chr2>...)
  2546.             <chr1>      the first character to compare
  2547.             <chr2>      the second character(s) to compare
  2548.             returns     t if predicate is true, nil otherwise
  2549.           Note: case is significant with these comparison functions.
  2550.  
  2551.         (char-lessp <chr1> <chr2>...)
  2552.         (char-not-greaterp <chr1> <chr2>...)
  2553.         (char-equalp <chr1> <chr2>...)
  2554.         (char-not-equalp <chr1> <chr2>...)
  2555.         (char-not-lessp <chr1> <chr2>...)
  2556.         (char-greaterp <chr1> <chr2>...)
  2557.             <chr1>      the first string to compare
  2558.             <chr2>      the second string(s) to compare
  2559.             returns     t if predicate is true, nil otherwise
  2560.           Note: case is not significant with these comparison functions.
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.  
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.  
  2579.  
  2580.  
  2581.  
  2582.  
  2583.  
  2584.  
  2585.  
  2586.  
  2587.  
  2588.  
  2589.  
  2590.  
  2591.  
  2592.  
  2593.  
  2594.  
  2595.  
  2596.  
  2597.  
  2598.  
  2599.  
  2600.  
  2601.  
  2602.  
  2603.         XLISP                INPUT/OUTPUT FUNCTIONS              Page 41
  2604.  
  2605.  
  2606.         INPUT/OUTPUT FUNCTIONS
  2607.  
  2608.         (read [<stream> [<eof> [<rflag>]]])  READ AN EXPRESSION
  2609.             <stream>    the input stream (default is standard input)
  2610.             <eof>       the value to return on end of file (default is nil)
  2611.             <rflag>     recursive read flag (default is nil)
  2612.             returns     the expression read
  2613.  
  2614.         (print <expr> [<stream>])  PRINT AN EXPRESSION ON A NEW LINE
  2615.             <expr>      the expression to be printed
  2616.             <stream>    the output stream (default is standard output)
  2617.             returns     the expression
  2618.  
  2619.         (prin1 <expr> [<stream>])  PRINT AN EXPRESSION
  2620.             <expr>      the expression to be printed
  2621.             <stream>    the output stream (default is standard output)
  2622.             returns     the expression
  2623.  
  2624.         (princ <expr> [<stream>])  PRINT AN EXPRESSION WITHOUT QUOTING
  2625.             <expr>      the expressions to be printed
  2626.             <stream>    the output stream (default is standard output)
  2627.             returns     the expression
  2628.  
  2629.         (pprint <expr> [<stream>])  PRETTY PRINT AN EXPRESSION
  2630.             <expr>      the expressions to be printed
  2631.             <stream>    the output stream (default is standard output)
  2632.             returns     the expression
  2633.  
  2634.         (terpri [<stream>])  TERMINATE THE CURRENT PRINT LINE
  2635.             <stream>    the output stream (default is standard output)
  2636.             returns     nil
  2637.  
  2638.         (flatsize <expr>)  LENGTH OF PRINTED REPRESENTATION USING PRIN1
  2639.             <expr>      the expression
  2640.             returns     the length
  2641.  
  2642.         (flatc <expr>)  LENGTH OF PRINTED REPRESENTATION USING PRINC
  2643.             <expr>      the expression
  2644.             returns     the length
  2645.  
  2646.  
  2647.  
  2648.  
  2649.  
  2650.  
  2651.  
  2652.  
  2653.  
  2654.  
  2655.  
  2656.  
  2657.  
  2658.  
  2659.  
  2660.  
  2661.  
  2662.  
  2663.  
  2664.  
  2665.  
  2666.  
  2667.  
  2668.  
  2669.         XLISP                 THE FORMAT FUNCTION                Page 42
  2670.  
  2671.  
  2672.         THE FORMAT FUNCTION
  2673.  
  2674.         (format <stream> <fmt> <arg>...)  DO FORMATTED OUTPUT
  2675.             <stream>    the output stream
  2676.             <fmt>       the format string
  2677.             <arg>       the format arguments
  2678.             returns     output string if <stream> is nil, nil otherwise
  2679.  
  2680.         The format string can contain characters that should be copied
  2681.         directly to the output and formatting directives.  The
  2682.         formatting directives are:
  2683.  
  2684.             ~A          print next argument using princ
  2685.             ~S          print next argument using prin1
  2686.             ~%          start a new line
  2687.             ~~          print a tilde character
  2688.  
  2689.  
  2690.  
  2691.  
  2692.  
  2693.  
  2694.  
  2695.  
  2696.  
  2697.  
  2698.  
  2699.  
  2700.  
  2701.  
  2702.  
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.  
  2711.  
  2712.  
  2713.  
  2714.  
  2715.  
  2716.  
  2717.  
  2718.  
  2719.  
  2720.  
  2721.  
  2722.  
  2723.  
  2724.  
  2725.  
  2726.  
  2727.  
  2728.  
  2729.  
  2730.  
  2731.  
  2732.  
  2733.  
  2734.  
  2735.         XLISP                  FILE I/O FUNCTIONS                Page 43
  2736.  
  2737.  
  2738.         FILE I/O FUNCTIONS
  2739.  
  2740.         (open <fname> &key :direction)  OPEN A FILE STREAM
  2741.             <fname>     the file name string or symbol
  2742.             :direction  :input or :output (default is :input)
  2743.             returns     a stream
  2744.  
  2745.         (close <stream>)  CLOSE A FILE STREAM
  2746.             <stream>    the stream
  2747.             returns     nil
  2748.  
  2749.         (read-char [<stream>])  READ A CHARACTER FROM A STREAM
  2750.             <stream>    the input stream (default is standard input)
  2751.             returns     the character
  2752.  
  2753.         (peek-char [<flag> [<stream>]])  PEEK AT THE NEXT CHARACTER
  2754.             <flag>      flag for skipping white space (default is nil)
  2755.             <stream>    the input stream (default is standard input)
  2756.             returns     the character (integer)
  2757.  
  2758.         (write-char <ch> [<stream>])  WRITE A CHARACTER TO A STREAM
  2759.             <ch>        the character to write
  2760.             <stream>    the output stream (default is standard output)
  2761.             returns     the character
  2762.  
  2763.         (read-line [<stream>])  READ A LINE FROM A STREAM
  2764.             <stream>    the input stream (default is standard input)
  2765.             returns     the string
  2766.  
  2767.         (read-byte [<stream>])  READ A BYTE FROM A STREAM
  2768.             <stream>    the input stream (default is standard input)
  2769.             returns     the byte (integer)
  2770.  
  2771.         (write-byte <byte> [<stream>])  WRITE A BYTE TO A STREAM
  2772.             <byte>      the byte to write (integer)
  2773.             <stream>    the output stream (default is standard output)
  2774.             returns     the byte (integer)
  2775.  
  2776.  
  2777.  
  2778.  
  2779.  
  2780.  
  2781.  
  2782.  
  2783.  
  2784.  
  2785.  
  2786.  
  2787.  
  2788.  
  2789.  
  2790.  
  2791.  
  2792.  
  2793.  
  2794.  
  2795.  
  2796.  
  2797.  
  2798.  
  2799.  
  2800.  
  2801.         XLISP               STRING STREAM FUNCTIONS              Page 44
  2802.  
  2803.  
  2804.         STRING STREAM FUNCTIONS
  2805.  
  2806.         These functions operate on unnamed streams.  An unnamed output
  2807.         stream collects characters sent to it when it is used as the
  2808.         destination of any output function.  The functions 'get-output-
  2809.         stream-string' and string or a list of characters.
  2810.  
  2811.         An unnamed input stream is setup with the 'make-string-input-
  2812.         stream' function and returns each character of the string when
  2813.         it is used as the source of any input function.
  2814.  
  2815.         (make-string-input-stream <str> [<start> [<end>]])
  2816.             <str>       the string
  2817.             <start>     the starting offset
  2818.             <end>       the ending offset + 1
  2819.             returns     an unnamed stream that reads from the string
  2820.  
  2821.         (make-string-output-stream)
  2822.             returns     an unnamed output stream
  2823.  
  2824.         (get-output-stream-string <stream>)
  2825.             <stream>    the output stream
  2826.             returns     the output so far as a string
  2827.           Note:  the output stream is emptied by this function
  2828.  
  2829.         (get-output-stream-list <stream>)
  2830.             <stream>    the output stream
  2831.             returns     the output so far as a list
  2832.           Note:  the output stream is emptied by this function
  2833.  
  2834.  
  2835.  
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842.  
  2843.  
  2844.  
  2845.  
  2846.  
  2847.  
  2848.  
  2849.  
  2850.  
  2851.  
  2852.  
  2853.  
  2854.  
  2855.  
  2856.  
  2857.  
  2858.  
  2859.  
  2860.  
  2861.  
  2862.  
  2863.  
  2864.  
  2865.  
  2866.  
  2867.         XLISP                   SYSTEM FUNCTIONS                 Page 45
  2868.  
  2869.  
  2870.         SYSTEM FUNCTIONS
  2871.  
  2872.         (load <fname> &key :verbose :print)  LOAD A SOURCE FILE
  2873.             <fname>     the filename string or symbol
  2874.             :verbose    the verbose flag (default is t)
  2875.             :print      the print flag (default is nil)
  2876.             returns     the filename
  2877.  
  2878.         (save <fname>) SAVE WORKSPACE TO A FILE
  2879.             <fname>     the filename string or symbol
  2880.             returns     t if workspace was written, nil otherwise
  2881.  
  2882.         (restore <fname>) RESTORE WORKSPACE FROM A FILE
  2883.             <fname>     the filename string or symbol
  2884.             returns     nil on failure, otherwise never returns
  2885.  
  2886.         (dribble [<fname>])  CREATE A FILE WITH A TRANSCRIPT OF A SESSION
  2887.             <fname>     file name string or symbol
  2888.                         (if missing, close current transcript)
  2889.             returns     t if the transcript is opened, nil if it is closed
  2890.  
  2891.         (gc)  FORCE GARBAGE COLLECTION
  2892.             returns     nil
  2893.  
  2894.         (expand <num>)  EXPAND MEMORY BY ADDING SEGMENTS
  2895.             <num>       the number of segments to add
  2896.             returns     the number of segments added
  2897.  
  2898.         (alloc <num>)  CHANGE NUMBER OF NODES TO ALLOCATE IN EACH SEGMENT
  2899.             <num>       the number of nodes to allocate
  2900.             returns     the old number of nodes to allocate
  2901.  
  2902.         (room)  SHOW MEMORY ALLOCATION STATISTICS
  2903.             returns     nil
  2904.  
  2905.         (type-of <expr>)  RETURNS THE TYPE OF THE EXPRESSION
  2906.             <expr>      the expression to return the type of
  2907.             returns     nil if the value is nil otherwise one of the symbols:
  2908.                           SYMBOL          for symbols
  2909.                           OBJECT          for objects
  2910.                           CONS            for conses
  2911.                           SUBR            for built-in functions
  2912.                           FSUBR           for special forms
  2913.                           CLOSURE         for defined functions
  2914.                           STRING          for strings
  2915.                           FIXNUM          for integers
  2916.                           FLONUM          for floating point numbers
  2917.                           CHARACTER       for characters
  2918.                           FILE-STREAM     for file pointers
  2919.                           UNNAMED-STREAM  for unnamed streams
  2920.                           ARRAY           for arrays
  2921.  
  2922.  
  2923.  
  2924.  
  2925.  
  2926.  
  2927.  
  2928.  
  2929.  
  2930.  
  2931.  
  2932.  
  2933.         XLISP                   SYSTEM FUNCTIONS                 Page 46
  2934.  
  2935.  
  2936.         (peek <addrs>)  PEEK AT A LOCATION IN MEMORY
  2937.             <addrs>     the address to peek at (integer)
  2938.             returns     the value at the specified address (integer)
  2939.  
  2940.         (poke <addrs> <value>)  POKE A VALUE INTO MEMORY
  2941.             <addrs>     the address to poke (integer)
  2942.             <value>     the value to poke into the address (integer)
  2943.             returns     the value
  2944.  
  2945.         (address-of <expr>)  GET THE ADDRESS OF AN XLISP NODE
  2946.             <expr>      the node
  2947.             returns     the address of the node (integer)
  2948.  
  2949.         (exit)  EXIT XLISP
  2950.             returns     never returns
  2951.  
  2952.  
  2953.  
  2954.  
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.  
  2967.  
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974.  
  2975.  
  2976.  
  2977.  
  2978.  
  2979.  
  2980.  
  2981.  
  2982.  
  2983.  
  2984.  
  2985.  
  2986.  
  2987.  
  2988.  
  2989.  
  2990.  
  2991.  
  2992.  
  2993.  
  2994.  
  2995.  
  2996.  
  2997.  
  2998.  
  2999.         XLISP                       EXAMPLES                     Page 47
  3000.  
  3001.  
  3002.         FILE I/O FUNCTIONS
  3003.  
  3004.         Input from a File
  3005.  
  3006.         To open a file for input, use the OPEN function with the keyword
  3007.         argument :DIRECTION set to :INPUT.  To open a file for output,
  3008.         use the OPEN function with the keyword argument :DIRECTION set
  3009.         to :OUTPUT.  The OPEN function takes a single required argument
  3010.         which is the name of the file to be opened.  This name can be in
  3011.         the form of a string or a symbol.  The OPEN function returns an
  3012.         object of type FILE-STREAM if it succeeds in opening the
  3013.         specified file.  It returns the value NIL if it fails.  In order
  3014.         to manipulate the file, it is necessary to save the value
  3015.         returned by the OPEN function.  This is usually done by
  3016.         assigning it to a variable with the SETQ special form or by
  3017.         binding it using LET or LET*.  Here is an example:
  3018.  
  3019.             (setq fp (open "init.lsp" :direction :input))
  3020.  
  3021.         Evaluating this expression will result in the file "init.lsp"
  3022.         being opened.  The file object that will be returned by the OPEN
  3023.         function will be assigned to the variable "fp".
  3024.  
  3025.         It is now possible to use the file for input.  To read an
  3026.         expression from the file, just supply the value of the "fp"
  3027.         variable as the optional "stream" argument to READ.
  3028.  
  3029.             (read fp)
  3030.  
  3031.         Evaluating this expression will result in reading the first
  3032.         expression from the file "init.lsp".  The expression will be
  3033.         returned as the result of the READ function.  More expressions
  3034.         can be read from the file using further calls to the READ
  3035.         function.  When there are no more expressions to read, the READ
  3036.         function will return NIL (or whatever value was supplied as the
  3037.         second argument to READ).
  3038.  
  3039.         Once you are done reading from the file, you should close it.
  3040.         To close the file, use the following expression:
  3041.  
  3042.             (close fp)
  3043.  
  3044.         Evaluating this expression will cause the file to be closed.
  3045.  
  3046.  
  3047.  
  3048.  
  3049.  
  3050.  
  3051.  
  3052.  
  3053.  
  3054.  
  3055.  
  3056.  
  3057.  
  3058.  
  3059.  
  3060.  
  3061.  
  3062.  
  3063.  
  3064.  
  3065.         XLISP                       EXAMPLES                     Page 48
  3066.  
  3067.  
  3068.         Output to a File
  3069.  
  3070.         Writing to a file is pretty much the same as reading from one.
  3071.         You need to open the file first.  This time you should use the
  3072.         OPEN function to indicate that you will do output to the file.
  3073.         For example:
  3074.  
  3075.             (setq fp (open "test.dat" :direction :output))
  3076.  
  3077.         Evaluating this expression will open the file "test.dat" for
  3078.         output.  If the file already exists, its current contents will
  3079.         be discarded.  If it doesn't already exist, it will be created.
  3080.         In any case, a FILE-STREAM object will be returned by the OPEN
  3081.         function.  This file object will be assigned to the "fp"
  3082.         variable.
  3083.  
  3084.         It is now possible to write to this file by supplying the value
  3085.         of the "fp" variable as the optional "stream" parameter in the
  3086.         PRINT function.
  3087.  
  3088.             (print "Hello there" fp)
  3089.  
  3090.         Evaluating this expression will result in the string "Hello
  3091.         there" being written to the file "test.dat".  More data can be
  3092.         written to the file using the same technique.
  3093.  
  3094.         Once you are done writing to the file, you should close it.
  3095.         Closing an output file is just like closing an input file.
  3096.  
  3097.             (close fp)
  3098.  
  3099.         Evaluating this expression will close the output file and make
  3100.         it permanent.
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106.  
  3107.  
  3108.  
  3109.  
  3110.  
  3111.  
  3112.  
  3113.  
  3114.  
  3115.  
  3116.  
  3117.  
  3118.  
  3119.  
  3120.  
  3121.  
  3122.  
  3123.  
  3124.  
  3125.  
  3126.  
  3127.  
  3128.  
  3129.  
  3130.  
  3131.         XLISP                       EXAMPLES                     Page 49
  3132.  
  3133.  
  3134.         A Slightly More Complicated File Example
  3135.  
  3136.         This example shows how to open a file, read each Lisp expression
  3137.         from the file and print it.  It demonstrates the use of files
  3138.         and the use of the optional "stream" argument to the READ
  3139.         function.
  3140.  
  3141.             (do* ((fp (open "test.dat" :direction :input))
  3142.                   (ex (read fp) (read fp)))
  3143.                  ((null ex) nil)
  3144.               (print ex))
  3145.  
  3146.  
  3147.  
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.  
  3156.  
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.  
  3173.  
  3174.  
  3175.  
  3176.  
  3177.  
  3178.  
  3179.  
  3180.  
  3181.  
  3182.  
  3183.  
  3184.  
  3185.  
  3186.  
  3187.  
  3188.  
  3189.  
  3190.  
  3191.  
  3192.  
  3193.  
  3194.  
  3195.  
  3196.  
  3197.  
  3198.  
  3199.  
  3200.  
  3201.  
  3202.  
  3203.  
  3204.  
  3205.  
  3206.  
  3207.  
  3208.  
  3209.  
  3210.  
  3211.  
  3212.  
  3213.  
  3214.  
  3215.  
  3216.  
  3217.  
  3218.  
  3219.  
  3220.  
  3221.  
  3222.  
  3223.  
  3224.  
  3225.  
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238.  
  3239.  
  3240.  
  3241.